﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using FreelanceToolkit.UI.Common;
using FreelanceToolkit.Data.Abstract;

namespace UI.Web
{
    public class MvcApplication : System.Web.HttpApplication
    {

        /// <summary>
        /// Registers the routes.
        /// </summary>
        /// <param name="routes">The routes.</param>
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );

        }

        /// <summary>
        /// Fires when the application starts
        /// </summary>
        protected void Application_Start()
        {
            SetupBase();

            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
        }

        /// <summary>
        /// Sets up the base class for the Web UI
        /// </summary>
        void SetupBase(){

            Base.ConnectionString = "";
            Base.clientInterface = new ClientSqlRepository();
        }

    }
}